package com.app.shop.controller;

import com.app.shop.bean.Goods;
import com.app.shop.dao.GoodsDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    GoodsDao goodsDao;
    @PostMapping("/list")
    public Map<String,Object> findAllGoods(){
        Map<String,Object> map = new HashMap();
        List<Goods> goodsList = goodsDao.findAll();

        System.out.println("====="+goodsList.get(0).imagePath);
        if(goodsList==null){
            map.put("result","false");
            map.put("msg","失败");
        }else{
            map.put("result","true");
            map.put("msg","成功");
            map.put("list",goodsList);
        }
        return  map;
    }
}
